﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DocViewer.Common;

public partial class Login : System.Web.UI.Page
{
    DY.BLL.tbl_User bllUser = new DY.BLL.tbl_User();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btn_Login_Click(object sender, EventArgs e)
    {
        string loginName = txt_LoginName.Text.Trim();
        string pwd = txt_PWD.Text.Trim();
        pwd = DocViewer.Common.DEncrypt.HashEncode.MD5(pwd);
        DY.Model.tbl_User modelUser = bllUser.GetModel(loginName);
        if (modelUser != null)
        {
            if (modelUser.PassWord == pwd)
            {
                CurUser.LoginName = loginName;
                CurUser.Id = modelUser.id;
                CurUser.Name = modelUser.TrueName;
                CurUser.Lang = modelUser.Avatar;
                CurUser.IsSuper = (loginName.ToLower() == "admin");
                string dir = SiteAbout.gStr("redir");
                if (string.IsNullOrEmpty(dir))
                    Response.Redirect("~/Default.aspx");
                else
                    Response.Redirect(dir);
            }
            else
            {
                RegisterClientScriptBlock("OK", "<script>alert('密码错误！')</script>");
            }
        }
        else
        {
            RegisterClientScriptBlock("OK", "<script>alert('用户不存在！')</script>");
        }
        
    }
}